home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / ELECTRON / 0989.ZIP / ESPRESSO.ARC / ESPRESSO.H < prev    next >
Text File  |  1987-03-13  |  7KB  |  186 lines

  1. /*
  2.     espresso.h -- Common header file for Espresso-mv
  3. */
  4. #define void int
  5.  
  6. #ifndef EXTERN
  7. #define EXTERN extern
  8. #endif
  9. #ifndef UNIX
  10. #define void int
  11. #endif
  12.  
  13. #include <stdio.h>
  14. #include <ctype.h>
  15. #include "set.h"
  16.  
  17.  
  18. /* Define a boolean type */
  19. #define bool int
  20. #define FALSE 0
  21. #define TRUE  1
  22. #define MAYBE 2
  23. #define print_bool(x) ((x) == 0 ? "FALSE" : ((x) == 1 ? "TRUE" : "MAYBE"))
  24.  
  25. /* Map many cube/cover types/routines into equivalent set types/routines */
  26. #define pcube                   pset
  27. #define new_cube()              set_new(cube.size)
  28. #define free_cube(r)            mem_free((char *) r)
  29. #define pcover                  pset_family
  30. #define new_cover(i)            sf_new(i, cube.size)
  31. #define free_cover(r)           sf_free(r)
  32. #define free_cubelist(T)        mem_free((char *) T[0]), mem_free((char *) T)
  33.  
  34. /* The cost structure stores the cost of a cover */
  35. typedef struct cost_struct {
  36.     int cubes, in, out, primes;
  37. } cost_t, *pcost; 
  38.  
  39. /* The pla_type field describes the input format of the PLA */
  40. #define F_type  1
  41. #define D_type  2
  42. #define R_type  4
  43. #define FD_type (F_type | D_type)
  44. #define FR_type (F_type | R_type)
  45. #define DR_type (D_type | R_type)
  46. #define FDR_type (F_type | D_type | R_type)
  47.  
  48. EXTERN struct {
  49.     char *key;
  50.     int value;
  51. } pla_types[]
  52. #ifdef INIT
  53.  = {"-f", F_type, "-r", R_type, "-d", D_type, "-fd", FD_type,
  54.    "-fr", FR_type, "-dr", DR_type, "-fdr", FDR_type, 0, 0}
  55. #endif
  56. ;
  57.  
  58. /* pair_t describes bit-paired variables */
  59. typedef struct {
  60.     int cnt, *var1, *var2;
  61. } pair_t, *ppair;
  62.  
  63. /* PLA_t stores the logical representation of a PLA */
  64. typedef struct {
  65.     pcover F, D, R;
  66.     char filename[200];         /* Filename */
  67.     int pla_type;               /* logical PLA format */
  68.     pcube phase;                /* phase to split into on-set and off-set */
  69.     ppair pair;                 /* how to pair variables */
  70. } PLA_t, *pPLA;
  71.  
  72. #define min(a,b)        ((a)>(b) ? (b) : (a))
  73. #define max(a,b)        ((a)<(b) ? (b) : (a))
  74. #define equal(a,b)      (strcmp(a,b) == 0)
  75.  
  76. #define CUBELISTSIZE(T)         (((pcube *) T[1] - T) - 3)
  77.  
  78. /* For documentation purposes */
  79. #define IN
  80. #define OUT
  81. #define INOUT
  82.  
  83. /* Definitions for the debug variable */
  84. #define COMPL           0x0001
  85. #define ESSEN           0x0002
  86. #define EXPAND          0x0004
  87. #define EXPAND1         0x0008
  88. #define GASP            0x0010
  89. #define IRRED           0x0020
  90. #define REDUCE          0x0040
  91. #define REDUCE1         0x0080
  92. #define SPARSE          0x0100
  93. #define TAUT            0x0200
  94. #define FTAUT           0x0400
  95. #define MINCOV          0x0800
  96. #define MINCOV1         0x1000
  97. #define SHARP           0x2000
  98.  
  99. #define VERSION \
  100.     "UC Berkeley, Espresso Version #2.1, Release date 2/28/85"
  101.  
  102. /* Define constants used for recording program statistics */
  103. #define TIME_COUNT      12
  104. #define READ_TIME       0
  105. #define COMPL_TIME      1
  106. #define ESSEN_TIME      2
  107. #define EXPAND_TIME     3
  108. #define IRRED_TIME      4
  109. #define REDUCE_TIME     5
  110. #define GEXPAND_TIME    6
  111. #define GIRRED_TIME     7
  112. #define GREDUCE_TIME    8
  113. #define MV_REDUCE_TIME  9
  114. #define RAISE_IN_TIME   10
  115. #define VERIFY_TIME     11
  116.  
  117. #define EXEC(fct, name, S)      {double t=ptime();fct;\
  118. if(trace)print_trace(S,name,ptime()-t);}
  119.  
  120. #define EXECUTE(fct,i,S)        {double t=ptime();fct;totals(t,i,S,&cost);}
  121.  
  122. #define EXECUTE_BREAK(fct,i,S)  {double t=ptime();fct;totals(t,i,S,&cost);\
  123. if(! cost_better(&best_cost, &cost))break;}
  124.  
  125. /* We need some global variables */
  126. EXTERN unsigned int debug;              /* debug parameter */
  127. EXTERN bool verbose_debug;              /* -v:  whether to print a lot */
  128. EXTERN char *total_name[TIME_COUNT];    /* basic function names */
  129. EXTERN double total_time[TIME_COUNT];   /* time spent in basic fcts */
  130. EXTERN int total_calls[TIME_COUNT];     /* # calls to each fct */
  131.  
  132. EXTERN bool mincov_exact;               /* -exact command line option */
  133. EXTERN bool force_irredundant;          /* -nirr command line option */
  134. EXTERN bool pos;                        /* -pos command line option */
  135. EXTERN bool kiss;                       /* -kiss command line option */
  136. EXTERN bool remove_essential;           /* -ness command line option */
  137. EXTERN bool single_expand;              /* -fast command line option */
  138. EXTERN bool summary;                    /* -s command line option */
  139. EXTERN bool trace;                      /* -t command line option */
  140.  
  141. #define CUBE_TEMP       10
  142. EXTERN struct {
  143.     int size;                   /* set size of a cube */
  144.     int num_vars;               /* number of variables in a cube */
  145.     int num_binary_vars;        /* number of binary variables */
  146.     int *first_part;            /* first element of each variable */
  147.     int *last_part;             /* first element of each variable */
  148.     int *part_size;             /* number of elements in each variable */
  149.     int *first_word;            /* first word for each variable */
  150.     int *last_word;             /* last word for each variable */
  151.     pset binary_mask;           /* Mask to extract binary variables */
  152.     pset mv_mask;               /* mask to get mv parts */
  153.     pset *var_mask;             /* mask to extract a variable */
  154.     pset *temp;                 /* an array of temporary sets */
  155.     pset fullset;               /* a full cube */
  156.     pset emptyset;              /* an empty cube */
  157.     unsigned int inmask;        /* mask to get odd word of binary part */
  158.     int inword;                 /* which word number for above */
  159.     int *sparse;                /* should this variable be sparse? */
  160.     char ***label;              /* label each part of each var */
  161. } cube;
  162.  
  163. EXTERN struct {
  164.     int *part_zeros;            /* count of zeros for each element */
  165.     int *var_zeros;             /* count of zeros for each variable */
  166.     int *parts_active;          /* number of "active" parts for each var */
  167.     bool *is_unate;             /* indicates given var is unate */
  168.     int vars_active;            /* number of "active" variables */
  169.     int vars_unate;             /* number of unate variables */
  170.     int best;                   /* best "binate" variable */
  171. } cdata;
  172.  
  173. #if BPI == 32
  174. #define DISJOINT 0x55555555
  175. #else 
  176. #define DISJOINT 0x5555
  177. #endif
  178.  
  179. /* system function declarations */
  180. extern char *malloc(), *strcpy(), *sprintf(), *sbrk();
  181. extern int printf(), fprintf(), scanf(), fscanf(), fflush(), ungetc();
  182. extern int fclose(), exit(), strlen(), strcmp();
  183. extern long atol();
  184.  
  185. #include "esptype.h"
  186.